import request from '@/utils/request'

// 查询文档目录树
export function getFolderTree(params) {
  return request({
    url: '/house/document/folder/tree',
    method: 'get',
    params: params
  })
}

// 新增文档目录
export function addFolder(data) {
  return request({
    url: '/house/document/folder',
    method: 'post',
    data: data
  })
}

// 修改文档目录
export function updateFolder(data) {
  return request({
    url: '/house/document/folder',
    method: 'put',
    data: data
  })
}

// 删除文档目录
export function delFolder(ids) {
  return request({
    url: '/house/document/folder/' + ids,
    method: 'delete'
  })
}

// 查询文档列表
export function listDocument(query) {
  return request({
    url: '/house/document/list',
    method: 'get',
    params: query
  })
}

// 查询文档详细
export function getDocument(id) {
  return request({
    url: '/house/document/' + id,
    method: 'get'
  })
}

// 上传文档
export function uploadDocument(data) {
  return request({
    url: '/house/document/upload',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 修改文档
export function updateDocument(data) {
  return request({
    url: '/house/document',
    method: 'put',
    data: data
  })
}

// 删除文档
export function delDocument(ids) {
  return request({
    url: '/house/document/' + ids,
    method: 'delete'
  })
}

// 导出文档
export function exportDocument(query) {
  return request({
    url: '/house/document/export',
    method: 'get',
    params: query
  })
}

// 获取指定目录下的文档
export function getDocumentsByFolder(folderId) {
  return request({
    url: '/house/document/folder/' + folderId,
    method: 'get'
  })
}

// 获取指定房屋的所有文档
export function getDocumentsByHouse(houseId) {
  return request({
    url: '/house/document/house/' + houseId,
    method: 'get'
  })
}

// 下载文档
export function downloadDocument(id) {
  return request({
    url: '/house/document/download/' + id,
    method: 'get',
    responseType: 'blob'
  })
}

// 预览文档
export function previewDocument(id) {
  return request({
    url: '/house/document/preview/' + id,
    method: 'get',
    responseType: 'blob'
  })
} 